{
  "properties" : { },
  "id" : "copy1735811229191d16467",
  "script" : null,
  "groupId" : "bf48efcbeb6f497a93c43937261d0d58",
  "name" : "5.循环历史数据",
  "createTime" : null,
  "updateTime" : 1735817530285,
  "lock" : null,
  "createBy" : null,
  "updateBy" : null,
  "path" : "/while_history",
  "method" : "GET",
  "parameters" : [ {
    "name" : "page",
    "value" : "1",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "size",
    "value" : "100",
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": -1,\n    \"message\": \"系统内部出现错误\",\n    \"data\": null,\n    \"timestamp\": 1735812459606,\n    \"executeTime\": 1060\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : null,
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "code",
      "value" : "-1",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "系统内部出现错误",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "null",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "timestamp",
      "value" : "1735805329033",
      "description" : "",
      "required" : false,
      "dataType" : "Long",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "executeTime",
      "value" : "10",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
import http;
import log;
import env;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.time.format.DateTimeFormatter;

var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

// 假设给定时间
var startTime = LocalDateTime.of(2024, 12, 30, 0, 0, 0); // 示例：2024年12月30日 00:00:00
var endTime = LocalDateTime.of(2025, 1, 2, 23, 59, 59); // 示例：2024年12月30日 00:00:00
var currentTime = LocalDateTime.now();

// 输出给定时间和当前时间
log.info("开始时间: " + startTime.format(formatter));
log.info("结束时间: " + endTime.format(formatter));

// 循环从给定时间递减每一天，并输出
var tmp_time = startTime;
var begin = "";
var end = "";
while (!tmp_time.isAfter(endTime)) {
    begin = tmp_time.format(formatter);
    tmp_time = tmp_time.plusDays(1); // 递增一天, +1
    end = tmp_time.format(formatter);

    log.info("begin----> {}", begin); // 输出每一天的日期部分
    log.info('end----> {}', end);
    // get请求,返回一个json对象, 1 预约会议 2 历史会议
    // 相关文档： https://www.ssssssss.org/magic-api/pages/module/http/
    var tt = http.connect('http://127.0.0.1:9710/test/syncData').contentType('application/json').param({
        "type": "2",
        "startTime": begin,
        "endTime": end,
    }).get().getBody();
    
    var status = tt['code'];
    if (code == 0) {
        log.info('返回的结果成功：{}', tt);
    } else {
        log.info('返回的结果失败：{}', tt);
        break;
    }
}


return {
    "now": currentTime.format(formatter),
    "begin": begin,
    "end: ": end
}